var config = {
  site: {
      MetaMaskNetId: '-1',
      domain:   location.hostname,
      protocol: location.protocol + '//',
      hostname: location.hostname,
      link: 'https://lk.forsage.io/',
      course: {
          value: `ETH_USD`,
          symbol: `$`,
      },
  },
  user: {
      refkey: '',
      address: '',
      isAuthSecure: false,
      sid: '34a07aae04b3f6fc09028e9ec3b08f08',
  },
  server: {
      date: [2020,08,30,04,37,28],
  },
  lang: {
  },
  locked: {
      buyLevel      : ``,
      authorization : ``,
      registration  : ``,
  },
  permissions: {
      buyLevel      : `0`,
  },
  isFramed: null,
  isMobile: true,
  haveWallet: window.ethereum || window.web3,
  previousUrl: `/`,
  gasPrice: 101,
};

let arr = config.site.domain.split('.');
if(arr.length > 2) {
  config.site.domain = arr.slice(arr.length - 2).join('.')
}

try {
config.isFramed = window != window.top || document != top.document || self.location != top.location;
} catch (e) {
config.isFramed = true;
}

window.addEventListener('DOMContentLoaded', function() {
  config.haveWallet = window.ethereum || window.web3;
});


/************************** */
function getCookie(name) {
    let matches = document.cookie.match(new RegExp(
      "(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)"
    ));
    return matches ? decodeURIComponent(matches[1]) : undefined;
}
  
function setCookie(name, value, options = {}) {
      let defaultOptions = {
          path: '/',
      };
      options = Object.assign(defaultOptions, options);
      if (options.expires instanceof Date) {
          options.expires = options.expires.toUTCString();
      } else {
          if(options.expires) {
              options.expires = new Date(Date.now() + Number.parseInt(options.expires) * 1000);
          }
      }
      let updatedCookie = encodeURIComponent(name) + "=" + encodeURIComponent(value);
      for (let optionKey in options) {
          updatedCookie += "; " + optionKey;
          let optionValue = options[optionKey];
          if (optionValue !== true) {
              updatedCookie += "=" + optionValue;
          }
      }
      document.cookie = updatedCookie;
}